<template>
	<view style="display: flex;margin:0 auto;flex-direction: column; width: 749rpx;">
		<view style="display: flex;flex-direction: column; margin: 50rpx auto 20rpx auto;width: 80%;background-color: white;border-radius: 20rpx;box-shadow: 1px 1px 5px #c2c2c2;padding: 30rpx;">
			<view style="display: flex; width: 100%;flex-direction: row;align-items: center;">
				<view style="display: flex;flex:1;">
					手机号
				</view>
				<view style="display: flex;flex: 4;">
					<!-- <input type="text"> -->
					<uni-easyinput style="width: 100%; border-radius: 15rpx;height: 80rpx;margin-left: 25rpx; " v-model="tel" type="number"
						placeholder="请输入手机号" />
				</view>
			</view>
			<view style="display: flex; width: 100%;flex-direction: row;align-items: center;margin-top: 30rpx;">
				<view style="display: flex;flex:1;">
					密 码
				</view>
				<view style="display: flex;flex: 4;">
					<uni-easyinput style="width: 100%; border-radius: 15rpx;height: 80rpx;margin-left: 25rpx; " v-model="mima" type="password"
						placeholder="请输入密码" />
				</view>
			</view>
		</view>	
		<view @click="denglu" style="display: flex;width: 40%;margin: 100rpx auto 20rpx auto;background-color: blue;border-radius: 20rpx;color: white;font-weight: bold;padding: 20rpx;align-items: center;justify-content: center;">
			登 陆
		</view>
		<view @click="wangjimima" style="display: flex;width: 40%;justify-content: end;margin: 10rpx auto;">
			忘记密码
		</view>
	</view>
</template>

<script>
	import md5 from '@/util/md5';
	export default {
		data() {
			return {
				meiyi_userinfo:{},
				item:{},
				tel:'',
				mima:'',
				shu3:'',//
			}
		},
		methods: {
			// 客户信息数据库调取
			denglu(){
				// 检查手机号是否正确
				let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
				if (!myreg.test(this.tel)) {
					return uni.showToast({
						title: '请输入正确的手机号',
						icon: 'none',
						mask: true
					})
				}
				uniCloud.callFunction({
					name:"yonghu",
					data:{
						leixing:2,//为2时，用户登陆 
						mima:md5(this.mima),
						tel:this.tel,
					}
				}).then(res=>{
					console.log('denglu',res)
					if(res.result==0){
						return uni.showToast({
							title: '账号或密码错误，请重新登陆',
							icon: 'none',
							duration:3000
						})
					}else if(res.result){
						this.shu3=res.result
						this.fun1()
					}
				})
			},
			async fun1(){
				uni.reLaunch({
					url: '/pages/shouye/shouye',
				})
			},
			// 跳转到修改密码
			wangjimima(){
				uni.navigateTo({
						url: "/pages/xiugaimima/xiugaimima"
				})
			},	
		}
	}
</script>

<style>

</style>
